const path = require("path");

const HtmlPlugin = require("html-webpack-plugin");

const htmlPlugin = new HtmlPlugin({
    template: "./src/index.html",
    filename: "index.html",
});

const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
    mode: "development",
    // mode: "production",
    // devtool: "eval-source-map",
    devtool: "nosources-source-map",
    entry: path.join(__dirname, "src/index1.js"),
    output: {
        path: path.join(__dirname, "dist"),
        filename: "js/bundle.js",
    },
    plugins: [htmlPlugin, new CleanWebpackPlugin()],
    devServer: {
        open: true,
        port: 3000,
        // host: "0.0.0.0",
    },
    resolve: {
        alias: { "@": path.join(__dirname, "src") },
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.less$/,
                use: ["style-loader", "css-loader", "less-loader"],
            },
            {
                test: /\.jpg|png|gif|ico$/,
                use: "url-loader?limit=1024&outputPath=img/",
            },
            {
                test: /\.js$/,
                use: "babel-loader",
                exclude: /node_modules/,
            },
        ],
    },
};
